package com.example.martian.controller;

import com.example.martian.service.CustodyService;
import com.example.martian.utils.Custody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

@Controller
@CrossOrigin
@RequestMapping("/custody/")
public class CustodyController {

    @Autowired
    private CustodyService custodyService;

    @RequestMapping(value = "testApi")
    @ResponseBody
    public Object testApi() throws Exception {
        return custodyService.testApi();
    }

    //查询账户详情
    @RequestMapping(value = "checkWellatMine")
    @ResponseBody
    public Object checkWellatMine() throws Exception {
        return custodyService.checkWellatMine();
    }

    //钱包页面展示
    @RequestMapping(value = "selectWellatByCoinFlash")
    @ResponseBody
    public Object selectWellatByCoinFlash(String address) throws IOException {
        return custodyService.selectWellatByCoinFlash(address);
    }

    //提现
    @RequestMapping(value = "coinWithdraw")
    @ResponseBody
    public Object coinWithdraw(String address,String addressKey,String toAddress,String coin,
                                   String withdraw_service,String value,String comment,Integer jypassword) throws Exception {
        return custodyService.coinWithdraw(address, addressKey, toAddress, coin, withdraw_service, value, comment,jypassword);
    }

    //划转
    @RequestMapping(value = "transfer")
    @ResponseBody
    public Object transfer(String address,String fromAddressKey,String toAddressKey,String coin,
                               String value,Integer type) throws Exception {
        return custodyService.transfer(address, fromAddressKey, toAddressKey, coin, value, type);
    }

    //USDT流水记录
    @RequestMapping(value = "selectUsdtRecord")
    @ResponseBody
    public Object selectUsdtRecord(String address,String coin) throws Exception {
        return custodyService.selectUsdtRecord(address, coin);
    }

    //挖矿账户收益展示
    @RequestMapping(value = "checkMiningEarnings")
    @ResponseBody
    public Object checkMiningEarnings(String address,Integer type){
        return custodyService.checkMiningEarnings(address,type);
    }

    //挖矿账户收益展示
    @RequestMapping(value = "selectHashrateByAddressAndCoin")
    @ResponseBody
    public Object selectHashrateByAddressAndCoin(String address,Integer type) {
        return custodyService.selectHashrateByAddressAndCoin(address,type);
    }

    //生成钱包公钥api
    @RequestMapping(value = "testGenerateKeysAndSignMessage")
    @ResponseBody
    public void testGenerateKeysAndSignMessage() {
        Custody.testGenerateKeysAndSignMessage();
    }

}
